/*
 * #depends subsonic-leftmenu-store.js
 */
Ext.ux.mattgoldspink.NowPlayingLeftPanel = Ext.extend(Ext.Panel, {
    constructor: function(config) {
        Ext.apply(config, {
			//hidden: true,
            dock: 'bottom',
			fit: true,
			height: 230,
			cls: 'now-playing',
			tpl: ['<h2>Now Playing:</h2>',
			'<img src="{[Ext.ux.mattgoldspink.subsonic.apiUrl]}/rest/getCoverArt.view?size=130&id={coverArt}&{[Ext.urlEncode(Ext.ux.mattgoldspink.subsonic.LoginDetails)]}" />',
			'<div class="song-meta">',
				'<div class="meta artist">{artist}</div>',
				'<div class="meta track">{name}</div>',
				'<div class="meta album">{album}</div>',
			'</div>'],
			listeners: {
				afterrender: this.hideEl,
				scope: this
			}
        });
        Ext.ux.mattgoldspink.NowPlayingLeftPanel.superclass.constructor.call(this, config);
		Ext.dispatch({
            controller: 'Ext.ux.mattgoldspink.subsonic.controllers.Player',
            action: 'registerPlayListener',
            listener: this
        });
		
    },
	hideEl: function(){
		Ext.defer(this.hide, 500, this, [{type: 'slide', direction: 'down'}]);
	},
	onPlay: function(track) {
		this.update(track.options.trackdata);
		this.show({type: 'slide', direction: 'up'});
		this.ownerCt.doLayout();
	}
});
